package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.BackupCircuitFlagHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

/**
 * @author xueyf
 * @Description
 * @Date 2021/5/25 14:35
 */
@Service
@AttrHandler(BackupCircuitFlagHandler.class)
public class BackupCircuitFlagLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    private static final String BACKUP_CIRCUIT_ATTR = "2_0000002";

    private static final String VALUE_Y = "1_0000106";

    private static final String VALUE_N = "1_0000107";

    private static final String MAIN_CIRCUIT_SERIAL_NUMBER = "200002085";

    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr mainCruitSerialNumberAttr = kiteInst.getAttr(MAIN_CIRCUIT_SERIAL_NUMBER);
        if(BACKUP_CIRCUIT_ATTR.equals(kiteAttr.getFieldName())){
            if(VALUE_Y.equals(kiteAttr.getValue())){
                mainCruitSerialNumberAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_D);
            }else if(VALUE_N.equals(kiteAttr.getValue())){
                mainCruitSerialNumberAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
                mainCruitSerialNumberAttr.setValue(null);
            }else {
                mainCruitSerialNumberAttr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
                mainCruitSerialNumberAttr.setValue(null);
            }
        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
